#include "ros/ros.h"
#include "sensor_msgs/JointState.h"

int main(int argc, char **argv)
{
    ros::init(argc, argv, "custom_joint_states_publisher");
    ros::NodeHandle nh;
    ros::Publisher pub = nh.advertise<sensor_msgs::JointState>("/joint_states", 10);
    ros::Rate rate(100); // 设置发布频率为100Hz

    while (ros::ok())
    {
        sensor_msgs::JointState joint_state;
        // 在这里设置关节状态信息

        pub.publish(joint_state);
         ros::spinOnce(); // 增加这一行，以便ROS可以处理任何在此期间到达的回调op
        rate.sleep();
    }

    return 0;
}
